package com.lagou.edu.controller;

import com.lagou.edu.service.CodeService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author: jie.zhao
 * @create: 2021/07/27 13:52
 */
@RestController
@RequestMapping("/api/code")
public class CodeController {

    @Resource
    private CodeService codeService;


    @GetMapping("/create/{email}")
    public Integer sendCode(@PathVariable String email){
        Integer code = codeService.sendCode(email);
        return code;
    }

    @GetMapping("/validate/{email}/{code}")
    public Integer validate(@PathVariable String email,@PathVariable String code){
        Integer result = codeService.validate(email,code);
        return result;
    }


}
